package imper.graphic.listener;

import imper.engine.entity.Country;
import imper.engine.entity.Industry;
import imper.engine.entity.IndustryType;
import imper.engine.util.ParameterManager;
import imper.graphic.view.IndustryView;

public class RemoveIndustryListener implements Runnable
{
	protected IndustryType _industryType;

	protected IndustryView _view;

	public RemoveIndustryListener(IndustryType pIndustryType, IndustryView pView)
	{
		this._industryType = pIndustryType;
		this._view = pView;
	}

	@Override
	public void run()
	{
		Country country = ParameterManager.getInstance().getMainCountry();
		Industry industry = country.getIndustry().get(_industryType.getId());
		if( industry != null)
		{
			int newValue = industry.getProduct() - 1;
			if (newValue >= 0)
			{
				industry.setProduct(newValue);
				this._view.refreshView();
			}
		}		

	}

}
